package com.animal.service;

import com.animal.dao.PetDao;
import com.animal.dao.PetDaoOracleImpl;
import com.animal.entity.Pet;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service("petService")
public class PetServiceImpl implements PetService{
    //创建PetService实现类对象
//    PetDao petDao = new PetDaoMySQLImpl();
    //提供petDao属性和对应的getter，setter
//    @Resource(name = "petDaoOracle")
    @Resource(type = PetDaoOracleImpl.class)
    private PetDao petDao;

    public PetDao getPetDao() {
        return petDao;
    }

    public void setPetDao(PetDao petDao) {
        this.petDao = petDao;
    }

//    PetDao petDao = PetDaoFactory.getInstance(PetDaoFactory.defaultBeanName);
    @Override
    public boolean save(Pet pet) {
        return petDao.insert(pet) > 0;
    }
}
